Fix/issues 940 941#946
Merged
Merged
Conversation
Amazon's orders_2026-01-01 model exposes Order.payment (OrderPayment -> paymentExecutions[] -> PaymentExecution), which was missing from the SDK. Add OrderPayment and PaymentExecution model classes and wire the Payment property into Order (DataMember "payment", constructor, ToString/Equals/ GetHashCode), following the existing model conventions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A single RateLimits instance is shared across all concurrent requests of a given RateLimitType. With no synchronization, parallel calls race on the token-bucket state: when the bucket is full, each thread advances LastRequest by ratePeriodMs, so the wait target keeps receding and the limiter never recovers until the process restarts (the reported "stuck until restart" symptom). The logic is correct single-threaded; the bug is purely concurrency. Gate NextRate behind a per-instance SemaphoreSlim (logic moved to NextRateCore). Each RateLimitType owns its own instance/gate, so distinct endpoints do not block each other. Also repair RateLimitsTests, which referenced the rolled-back WaitForPermittedRequest API and no longer compiled, and add a concurrency regression test that drives 10 parallel requests and asserts they drain within a bounded window. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses concurrency issues in the shared rate-limiter implementation and expands the Orders V20260101 model surface to include payment details.
Changes:
- Serialize
RateLimits.NextRate(...)execution with a per-instanceSemaphoreSlimto prevent token-bucket state corruption under parallel calls. - Update/add NUnit tests to validate expected wait timing and add a regression test for concurrent draining behavior.
- Add Orders
V20260101payment models (OrderPayment,PaymentExecution) and wireOrder.Paymentinto theOrdermodel.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Source/Tests/RateLimitsTests.cs | Updates the rate-limit timing test to use NextRate and adds a parallelism regression test. |
| Source/FikaAmazonAPI/Utils/RateLimits.cs | Adds a semaphore gate to serialize access to shared token-bucket state in NextRate. |
| Source/FikaAmazonAPI/AmazonSpApiSDK/Models/OrdersV20260101/PaymentExecution.cs | Introduces a new model representing a single payment execution. |
| Source/FikaAmazonAPI/AmazonSpApiSDK/Models/OrdersV20260101/OrderPayment.cs | Introduces a new model representing an order’s payment information (list of executions). |
| Source/FikaAmazonAPI/AmazonSpApiSDK/Models/OrdersV20260101/Order.cs | Adds Payment to the Order model, including ctor, equality, string output, and hashing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
45
to
47
| /// <param name="rateLimitType">An enum representing the rate limit policy for the resource in use</param> | ||
| /// <param name="cancellationToken">The cancellation token</param> | ||
| /// <returns></returns> |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
This was referenced Jun 12, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



No description provided.